package com.copa.module.system.controller;

import com.copa.config.QiniuConfig;
import com.copa.domain.ResponseDto;
import com.qiniu.util.Auth;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * @author copa
 * @createDate 2021-02-24 12:50
 * @function
 */
@RestController
@Api(value = "文件上传控制器",tags = {"文件上传"})
public class FileUploadController {

    @GetMapping("/file/uploadToken")
    @ApiOperation("获取上传文件的token")
    public ResponseDto<String> uploadToken(){
        Auth auth = Auth.create(QiniuConfig.ACCESS_KEY, QiniuConfig.SECRET_KEY);
        String upToken = auth.uploadToken(QiniuConfig.BUCKET);
        return ResponseDto.success(upToken);
    }

}
